﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class ProductionTechnologyDetailsMapping : IEntityTypeConfiguration<ProductionTechnologyDetails>
    {
        public void Configure(EntityTypeBuilder<ProductionTechnologyDetails> builder)
        {
            builder.ToTable("ProductionTechnologyDetails");
            builder.HasKey(ptd => ptd.ProductionTechnologyDetailId);
            builder.Property(ptd => ptd.ProductionTechnologyDetailId)
                .HasComment("工艺明细主键，自动编号");

            builder.Property(ptd => ptd.ProductionTechnologyId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("工艺主键，外键（ProductionTechnologies）");

            builder.Property(ptd => ptd.ProductionProcessId)
                .IsRequired()
                .HasColumnType("varchar(20)")
                .HasComment("工序主键，外键（ProductionProcesses）");

            builder.Property(ptd => ptd.Status)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(0)
                .HasComment("数据状态（0正常，1删除），默认值0");

            builder.Property(ptd => ptd.CreateUserId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("创建人，外键（Users）");

            builder.Property(ptd => ptd.CreateTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(ptd => ptd.LastUpdateUserId)
                .HasColumnType("int")
                .HasComment("最后一次修改人，外键（Users）");

            builder.Property(ptd => ptd.LastUpdateTime)
                .HasColumnType("datetime")
                .HasComment("最后一次修改时间");
        }
    }

}
